<template>
  <!-- <div class="app-container home">
    <el-row :gutter="20">
      <el-col :sm="24" :lg="24">
        <blockquote class="text-warning" style="font-size: 14px">
          领取阿里云通用云产品1888优惠券
          <br />
          <el-link
            href="https://www.aliyun.com/minisite/goods?userCode=brki8iof"
            type="primary"
            target="_blank"
            >https://www.aliyun.com/minisite/goods?userCode=brki8iof</el-link
          >
          <br />
          领取腾讯云通用云产品2860优惠券
          <br />
          <el-link
            href="https://cloud.tencent.com/redirect.php?redirect=1025&cps_key=198c8df2ed259157187173bc7f4f32fd&from=console"
            type="primary"
            target="_blank"
            >https://cloud.tencent.com/redirect.php?redirect=1025&cps_key=198c8df2ed259157187173bc7f4f32fd&from=console</el-link
          >
          <br />
          阿里云服务器折扣区
          <el-link href="http://aly.ruoyi.vip" type="primary" target="_blank"
            >>☛☛点我进入☚☚</el-link
          >
          &nbsp;&nbsp;&nbsp; 腾讯云服务器秒杀区
          <el-link href="http://txy.ruoyi.vip" type="primary" target="_blank"
            >>☛☛点我进入☚☚</el-link
          ><br />
          <h4 class="text-danger">
            云产品通用红包，可叠加官网常规优惠使用。(仅限新用户)
          </h4>
        </blockquote>

        <hr />
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :sm="24" :lg="12" style="padding-left: 20px">
        <h2>档案管理系统</h2>
      </el-col>

      <el-col :sm="24" :lg="12" style="padding-left: 50px">
        <el-row>
          <el-col :span="12">
            <h2>技术选型</h2>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="6">
            <h4>后端技术</h4>
            <ul>
              <li>SpringBoot</li>
              <li>Spring Security</li>
              <li>JWT</li>
              <li>MyBatis</li>
              <li>Druid</li>
              <li>Fastjson</li>
              <li>...</li>
            </ul>
          </el-col>
          <el-col :span="6">
            <h4>前端技术</h4>
            <ul>
              <li>Vue</li>
              <li>Vuex</li>
              <li>Element-ui</li>
              <li>Axios</li>
              <li>Sass</li>
              <li>Quill</li>
              <li>...</li>
            </ul>
          </el-col>
        </el-row>
      </el-col>
    </el-row>
    <el-divider />
  </div> -->

  <div class="panels">
    <div class="panel-item" id="chart-pie"></div>
    <div class="panel-item">
      <div class="title">档案总数</div>
      <div class="num">{{docNums}}</div>
    </div>
  </div>

</template>

<script>
import * as echarts from 'echarts';
require('echarts/theme/macarons'); // echarts theme
import resize from './dashboard/mixins/resize';
import { getDocNums, getFolderNums } from "@/api/am/homepage";

export default {
  name: "Index",
  mixins: [resize],
  data() {
    return {
      // 版本号
      version: "3.8.6",
      chart: null,
      docNums: 0,
    };
  },
  mounted() {
    this.$nextTick(() => {
      // this._initChartPie()
      this._getDocNums()
      this._getFolderNums()
    })
  },
  beforeDestroy() {
    if (!this.chart) {
      return
    }
    this.chart.dispose()
    this.chart = null
  },
  methods: {
    goTarget(href) {
      window.open(href, "_blank");
    },
    _getDocNums() {
      getDocNums().then(res => {
        console.log(res)
        this.docNums = res.data
      })
    },
    _getFolderNums() {
      getFolderNums().then(res => {
        console.log(res);
        let data = [];
        res.data.forEach(item => {
          data.push({
            name: item.name,
            value: item.fileCount
          })
        });
        this._initChartPie(data);
      })
    },
    _initChartPie(data) {
      let pie = document.getElementById('chart-pie');
      this.chart = echarts.init(pie, 'macarons');

      this.chart.setOption({
        color: ["#94beff", "#abec8c", "#f69682", "#ffc079", "#b09ffc", "#9ae3ed", "#d8e385", "#f6b6ca", "#cec3ff", "#e4aeed"],
        title: {
          text: '档案编目统计图',
          subtext: '',
          left: 'center'
        },
        tooltip: {
          trigger: 'item',
          formatter: '{a} <br/>{b} : {c} ({d}%)'
        },
        legend: {
          orient: 'vertical',
          top: '40',
          left: '10',
        },
        series: [
          {
            name: '档案编目',
            type: 'pie',
            radius: '60%',
            // center: ['50%', '50%'],
            emphasis: {
                itemStyle: {
                    shadowBlur: 10,
                    shadowOffsetX: 0,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
            },
            data: data
          }
        ]
      })
    }
  }
};
</script>

<style scoped lang="scss">
.home {
  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
  }
  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #eee;
  }
  .col-item {
    margin-bottom: 20px;
  }

  ul {
    padding: 0;
    margin: 0;
  }

  font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;

  ul {
    list-style-type: none;
  }

  h4 {
    margin-top: 0px;
  }

  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }

  p {
    margin-top: 10px;

    b {
      font-weight: 700;
    }
  }

  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }
  }
}

.panels {
  display: flex;
  padding: 80px;
}
.panel-item {
  flex: 1;
  height: 500px;
  .title {
    text-align: center;
    color: #31A0D7;
    font-size: 18px;
  }
  .num {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 80%;
    font-weight: bold;
    font-size: 100px;
    color: #31A0D7;
  }
}
</style>

